const mongoose = require('mongoose');

const Schema = mongoose.Schema;
const CommentSchema = new Schema({
  userId: {
    type: Schema.Types.ObjectId,
    ref: 'User' // 使用传递的userId对User表进行进行联表查询
  },
  goodsId: String,
  userName: String,
  content: String,
  commentTime: {
    type: Date,
    default: Date.now, // 不要使用now()否则不会自动更新
  }
})

// 发布模型
mongoose.model('Comment', CommentSchema);